   package com.dkd.manage.controller;

   import com.dkd.common.core.domain.R;
   import io.swagger.annotations.Api;
   import io.swagger.annotations.ApiOperation;
   import io.swagger.annotations.ApiResponse;
   import io.swagger.annotations.ApiResponses;
   import java.util.List;
   import javax.servlet.http.HttpServletResponse;
   import org.springframework.security.access.prepost.PreAuthorize;
   import org.springframework.beans.factory.annotation.Autowired;
   import org.springframework.web.bind.annotation.*;

   import com.dkd.common.annotation.Log;
   import com.dkd.common.core.controller.BaseController;
   import com.dkd.common.core.domain.AjaxResult;
   import com.dkd.common.enums.BusinessType;
   import com.dkd.manage.domain.TaskDetails;
   import com.dkd.manage.service.ITaskDetailsService;
   import com.dkd.common.utils.poi.ExcelUtil;
   import com.dkd.common.core.page.TableDataInfo;

   /**
    * 工单详情Controller
    * 
    * @author Ashely
    * @date 2024-11-19
    */
   @RestController
   @RequestMapping("/manage/taskDetails")
   @Api(tags = "工单详情管理")
   public class TaskDetailsController extends BaseController
   {
       @Autowired
       private ITaskDetailsService taskDetailsService;

       /**
        * 查询工单详情列表
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:list')")
       @GetMapping("/list")
       @ApiOperation(value = "查询工单详情列表", notes = "根据条件查询工单详情列表")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public TableDataInfo list(TaskDetails taskDetails)
       {
           startPage();
           List<TaskDetails> list = taskDetailsService.selectTaskDetailsList(taskDetails);
           return getDataTable(list);
       }

       /**
        * 导出工单详情列表
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:export')")
       @Log(title = "工单详情", businessType = BusinessType.EXPORT)
       @PostMapping("/export")
       @ApiOperation(value = "导出工单详情列表", notes = "导出符合条件的工单详情列表为Excel文件")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public void export(HttpServletResponse response, TaskDetails taskDetails)
       {
           List<TaskDetails> list = taskDetailsService.selectTaskDetailsList(taskDetails);
           ExcelUtil<TaskDetails> util = new ExcelUtil<TaskDetails>(TaskDetails.class);
           util.exportExcel(response, list, "工单详情数据");
       }

       /**
        * 获取工单详情详细信息
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:query')")
       @GetMapping(value = "/{detailsId}")
       @ApiOperation(value = "获取工单详情详细信息", notes = "根据ID获取工单详情详细信息")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
       {
           return success(taskDetailsService.selectTaskDetailsByDetailsId(detailsId));
       }

       /**
        * 新增工单详情
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:add')")
       @Log(title = "工单详情", businessType = BusinessType.INSERT)
       @PostMapping
       @ApiOperation(value = "新增工单详情", notes = "新增一条工单详情记录")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public AjaxResult add(@RequestBody TaskDetails taskDetails)
       {
           return toAjax(taskDetailsService.insertTaskDetails(taskDetails));
       }

       /**
        * 修改工单详情
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:edit')")
       @Log(title = "工单详情", businessType = BusinessType.UPDATE)
       @PutMapping
       @ApiOperation(value = "修改工单详情", notes = "根据ID修改工单详情记录")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public AjaxResult edit(@RequestBody TaskDetails taskDetails)
       {
           return toAjax(taskDetailsService.updateTaskDetails(taskDetails));
       }

       /**
        * 删除工单详情
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:remove')")
       @Log(title = "工单详情", businessType = BusinessType.DELETE)
       @DeleteMapping("/{detailsIds}")
       @ApiOperation(value = "删除工单详情", notes = "根据ID删除工单详情记录")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public AjaxResult remove(@PathVariable Long[] detailsIds)
       {
           return toAjax(taskDetailsService.deleteTaskDetailsByDetailsIds(detailsIds));
       }

       /**
        * 查看工单补货详情
        */
       @PreAuthorize("@ss.hasPermi('manage:taskDetails:list')")
       @GetMapping(value = "/byTaskId/{taskId}")
       @ApiOperation(value = "查看工单补货详情", notes = "根据任务ID查看工单补货详情")
       @ApiResponses({
           @ApiResponse(code = 200, message = "成功"),
           @ApiResponse(code = 401, message = "未授权"),
           @ApiResponse(code = 403, message = "禁止访问"),
           @ApiResponse(code = 404, message = "未找到资源")
       })
       public R<List<TaskDetails>> byTaskId(@PathVariable("taskId") Long taskId)
       {
           TaskDetails taskDetailsParam = new TaskDetails();
           taskDetailsParam.setTaskId(taskId);
           return R.ok(taskDetailsService.selectTaskDetailsList(taskDetailsParam));
       }
   }
   